package com.nf.health.app.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.nf.health.app.R;
import com.nf.health.app.utils.TextUtilTools;

import java.util.List;
import java.util.Map;

/** 
 *
 * @Description: 九种体质  检测结果页面
 * @author changpeng
 * @date 20170606
 *  
 */
public class NewCheckResultAdapter extends BaseAdapter {

	private Context context;
	private List<Map<String,String>> doctors;


	public NewCheckResultAdapter(Context context, List<Map<String, String>> doctors) {
		super();
		this.context = context;
		this.doctors = doctors;
	}

	@Override
	public int getCount() {
		if(doctors == null){
			return 0;
		}
		return doctors.size();
	}

	@Override
	public Object getItem(int position) {
		return doctors.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		ViewHolder holder = null;
		if (convertView == null) {
			convertView = View.inflate(context, R.layout.item_new_result, null);
			holder = new ViewHolder();
			holder.tvResult = (TextView) convertView.findViewById(R.id.tv_result);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		String htmlText = "<font color='#FB9754'>"+doctors.get(position).get("eval_name") + "</font><br>" + doctors.get(position).get("eval_value");
		TextUtilTools.setTextFromHtml(holder.tvResult,htmlText);
		return convertView;
	}
	static class ViewHolder {
		TextView tvResult;
	}
}
